﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

// Condition: Write a program that finds the maximal increasing sequence in an array.

    class IncreaseSequence
    {
        static void Main()
        {
            // 1. initialize array

             Console.Write("Enter number of element in integer array: ");
             int n = int.Parse(Console.ReadLine());
             int[] myArr = new int[n];
             Console.WriteLine("Enter elements of integer array: ");
             for (int index = 0; index < n; index++)
             {
                Console.Write("element[{0}]= ", index);
                myArr[index] = int.Parse(Console.ReadLine());
             }
            Console.WriteLine();

         

            // 2. helping variables

            int len = 1;
            int end = 0;
            int bestEnd = 0;
            int bestLen = 1;
            int count = 0;

            // 3. Solution  

            for (int i = 1; i < myArr.Length; i++)
            {
                if (myArr[i] <= myArr[i - 1])
                {
                    len = 1;
                    continue;
                }
                if (myArr[i] > myArr[i - 1])
                {
                    len++;
                    end = i;
                    
                }
                if (bestLen == len && bestLen != 1)
                {
                    count++;
                }
                if (bestLen < len)
                {
                    bestLen = len;
                    bestEnd = end;
                    count = 0;
                }
            }

            // 4. Output the result 

            if (bestEnd == 0)
            {
                Console.WriteLine("No increasing sequence of elements.");
            }
            else if (count != 0)
            {
                Console.WriteLine("There are more than one increasing sequence with same length.");
            }
            else if (bestEnd != 0)
            {
                Console.Write("The maximum sequence of increasing elements is: { ");
                for (int i = bestEnd+1-bestLen; i <= bestEnd; i++)
                {
                    Console.Write("{0} ", myArr[i]);
                }
                Console.Write("}");
            }
            Console.WriteLine();

        }
    }

